#ifndef _PROBE_H
#define _PROBE_H

#pragma pack(1)
typedef struct {
    unsigned char rude_speed[32];
    unsigned char master_speed[32];
    unsigned char switch_speed[32];
    unsigned char rab_speed[32];  //master/high roller
    unsigned char roll_speed[32]; //auxiliary roller
    unsigned char low_speed[32];
}MH_SPEED, *PMH_SPEED;

typedef struct {
    ushort pos[9][2][16]; //0-to left, 1-to right
   // uchar out[2][16];
}YARN_STOP, *PYARN_STOP;

typedef struct {
    ushort f2[32];
    ushort b2[32];
    ushort f4[32];
    ushort b4[32];
    ushort all[32];
    ushort f3[32];
    ushort b3[32];
    ushort f1[32];
    ushort b1[32];
    ushort data[7][32];
}MH_DUMU, *PMH_DUMU;

typedef struct {
    ushort front2[32];
    ushort back2[32];
    ushort all_mouth[32];
    ushort front1[32];
    ushort back1[32];
}MH_1DUMU, *PMH_1DUMU;

typedef struct {
    char data[12][100];
}YARN_BEFORE_NEEDLE, *PYARN_BEFORE_NEEDLE;

typedef struct {
    uchar data[16][2];
}YARN_EXCHANGE, *PYARN_EXCHANGE;

typedef struct {
    char enable;
    char yc[16];
}PIECE;

typedef struct {
    char src_enable;
    PIECE piece[8];
}EXT_PIECE, *PEXT_PIECE;

typedef struct
{
    short data[8];
}SINKSECTION;

typedef struct
{
    SINKSECTION section[8];
    short fzero;
    short bzero;
    short fzero2;
    short bzero2;
}SINK_DATA, *SINK_PIECE;

typedef struct
{
    short value[4][8];
}CAM_DATA, *CAM_PIECE;

typedef struct
{
    int start_time;
    char speed[32];
}YARNFEEDER_DATA, *YARNFEEDER_PIECE;

typedef struct {
   struct {
       ushort Integer;
       ushort Float;
   }type;
   int len;
   int total_pulse;
   int zero_pulse;
   int lgrz;
   int lglz;    //5
   int rgrz;
   int rglz;
   int qdb_enable;
   int rock_speed;
   int sink_enable;    //10
   int shake_level;
   int rock_com;
   int motor_com;
   int xzq_time;
   int mac_no;      //15
   int dumu_reset;
   int dumu_work;
   int xzq_2left_comp;
   int xzq_2right_comp;
   int inch_pulse;      //20
   int max_speed;
   int retain1;
   int can_work;
   int sink_work;
   int retain2;             //25
   int xzq_resel; // 选针器重\E9\80?
   int rab_compe; // 主罗拉补\E5\81?
   int y3rz;        //后面新增的
   int y3lz;
}SYS_PARAM, *PSYS_PARAM;

typedef struct {
    int start_needle;
    int ret_len;
    int ext_inter;
    int ext_enable;
    short hd_end;
    short hd_start;
    int hd_num;
    int save_screen;
    int low_speed;
    int knot_speed;
    int limit_speed;
    int knot_low_zhuan;
    int auto_zero_cloth;
    int rab_percent;
    int left_feeder_enable;
    int right_feeder_enable;
    int feeder_mode;
    int board_mode;
    int board_yarn;
    int cam_lock;
    int empty_speed;
    int rab_speed;
    int rab_open_speed;
    int dumu_add_for_stop;
    int second_dumu_needle;
    int null_data;
    int yarn_take_mode;
    int auto_line_set;
    int return_state;
    int rab_copy_enable;
    int data[19];
}WORK_PARAM, *PWORK_PARAM;
typedef struct{
    short null_data1;
    short out_cercle_later;
    short yarn_left_len;
    short scissor_times;
    short yarn_right_len;
     short rab_out_cercle;
    short gou_position;
    short down_safer_speed;
    short safe_position;
    short board_reset_speed;
    short roll_close_position;
    short out_cercle_down_speed;
    short roll_out_cercle;
    short board_slow_position;
    short board_up_start_speed;
    short board_slow_speed;
    short board_up_add_speed;
    short rab_speed;
    short board_up_slow_speed;
    short rab_timer;
    short board_up_add_position;
    short board_up_position;
    short board_up_slow_position;
    short rab_close_position;
    short rab_close_speed;
    short rab_open_speed;
    short  forfex_enable;
    short null_data2;
}BOARD_PARAM, *PBOARD_PARAM;

typedef struct{
	short shield_probe_len;
	short tran_dumu_enable;
	short data[22];
}HIDE_PARAM, *PHIDE_PARAM;

typedef struct {
    short select1_to_mac_left_len;
    short select2_to_mac_left_len;
    short select3_to_mac_left_len;
    short select4_to_mac_left_len;
    short select_piece;   //4
    short select_mode;
    short rock_mode;
    short rock_zero_dir;
    short language;
    short red_light_time; //9
    short select_sect;
    short sever_type;
    short probe_to_mac_left_len;
    short select_start;
    short yarn_type;
    short sink_dir;
    short dumu1_to_mac_left_len;
    short dumu2_to_mac_left_len;
    short dumu3_to_mac_left_len;
    short dumu4_to_mac_left_len;
    short fuel_gab;
    short fuel_time;
    short select5_to_mac_right_len;
    short select6_to_mac_right_len;
    short mac_width;
    short null_data;
    short sink1_to_mac_left_len;
    short sink2_to_mac_left_len;
}MAC_PARAM, *PMAC_PARAM;

typedef struct {
    short pos[3][32];       /* 0-翻针\E4\BD?1-编织\E4\BD?2-针对针位 */
    short zero;             /* 零位补偿 */
    short any;              /* 万能\E4\BD?*/
    short rock_space;   /* 摇床间隙补偿 */
}ROCK_POS, *PROCK_POS;

struct _STITCH_AMEND {
    short f2;
    short b2;
    short f4;
    short b4;
    short f1;
    short b1;
    short f3;
    short b3;
	 short all[40];
};
typedef struct _STITCH_AMEND  STITCH_AMEND;
typedef struct _STITCH_AMEND* PSTITCH_AMEND;

struct _PROBE_DATA{
    pthread_mutex_t *pudp_mutex;
    MH_UDP *pudp;
    int *psend_state;
    MH_SPEED speed;
    MH_DUMU dumu;
    PKNIT_PAGE pcon;
    ushort con_line;
    uchar cam;
    YARN_STOP yarn_stop;
    YARN_EXCHANGE yarn_exchange;
    ushort flw_width;
    ushort flw_height;
    uchar *pflw;
    YARN_BEFORE_NEEDLE yarn_before;
    EXT_PIECE extpiece;
    SYS_PARAM sys_param;
    WORK_PARAM work_param;
    MAC_PARAM mac_param;
    ROCK_POS rock_pos;
    STITCH_AMEND stitch_amend;
    ALARM_MASK alarm_mask;
    CLOTH_NUM cloth_num;
};
#pragma pack()

#define CNT_BIT         (0x01 << 0)
#define PAT_BIT         (0x01 << 1)
#define STITCH_BIT      (0x01 << 2)
#define SPEED_BIT       (0x01 << 3)
#define SYSPRM_BIT      (0x01 << 4)
#define WORKPRM_BIT     (0x01 << 5)
#define MACHPRM_BIT     (0x01 << 6)
#define ROCK_BIT        (0x01 << 7)
#define YARNSTOP_BIT    (0x01 << 8)
#define YARNBEFORE_BIT  (0x01 << 9)
#define EXTPIECE_BIT    (0x01 << 10)
#define YARNCHNG_BIT    (0x01 << 11)
#define CLOTHNUM_BIT    (0x01 << 12)
#define ALARMMASK_BIT   (0x01 << 13)
#define STITCHAMEND_BIT (0x01 << 14)
#define ALL_COMPLETE    0x7FFF

#endif
